﻿<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>
  <xsl:template match="/">
  <link rel="stylesheet" type="text/css" href="/_layouts/15/VPLink2013/css/trombi2.css?ver=1.1" />
    <script type="text/javascript" src="/_layouts/15/VPLink2013/js/jquery.min.js">
	</script>
    <script type="text/javascript">
    <![CDATA[ 
	$(document).ready(function(){
	 $('tr.serviceHeader').click(function(){
		$(this).parent().children('tr').each(function(){
			if($(this).hasClass('unselectedBody')){
				$(this).removeClass('unselectedBody');
				$(this).addClass('selectedBody');
			}
			else{
				$(this).removeClass('selectedBody');
				$(this).addClass('unselectedBody');
			}
		});
	 });
	 });
      var selected = null;
      var services = '';
      function selectService(arg)
      {
        unselectService();
        if(arg != '[object]') arg = document.getElementById(arg);
        arg.style.color = '#e52d87';
        document.getElementById('selectedService').value = arg.getAttribute('serviceName');
        selected = arg;
      }

      function unselectService()
      {
        if(selected && selected == '[object]')
        {
          selected.style.color = '#304500';
          selected = null;
        }
        document.getElementById('selectedService').value = '';
      }

      function unselectServices(arg)
      {
        var arrServices = services.split(';');
        arrServices.pop();
        for(var i = 0; i < arrServices.length; i++)
        {
           if(arrServices[i] != arg)
           {
             service = document.getElementById(arrServices[i]);
             service.style.color = '#304500';
           }
        }
      }
      ]]>
    </script>
    <input type="hidden" id="selectedService" name="selectedService" value="" />
    <table style="width:100%;border: 1px solid #dddcdc;">
      <tr>
        <td style="width:28%;vertical-align:top;">
          <table style="width:100%;vertical-align:top;border-right: 1px solid #dddcdc;">
            <tr>
              <td style="width:100%;vertical-align:top;padding-bottom:5px;">
                <table style="width:100%;vertical-align:top;">
                  <tr class="ms-WPHeader">
                    <td id="WebPartTitleWPQ3" title="Trombinoscope" style="WIDTH: 100%">
                      <h3 class="ms-standardheader ms-WPTitle">
                        <nobr>
                          <span style="font-size:10pt">Trombinoscope</span>
                          <span id="WebPartCaptionWPQ3"></span>
                        </nobr>
                      </h3>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
            <tr>
              <td class="leftNavBG" style="width:100%;vertical-align:top;border-bottom: 1px solid #dddcdc; border-top: 1px solid #dddcdc;">
                <table class="leftNav" cellSpacing="0" cellPadding="0" border="0" style="width:100%;border:0px;">
                  <xsl:apply-templates select="/Services/Service" mode="Left" />
                </table>
              </td>
            </tr>
          </table>
        </td>
        <td class="trombiMiddle" style="width:75%;">
          <table style="width:100%;height:100%;">
            <tr>
				<td>
					<div style="margin-right:210px; text-align:right">
						<a href="http://vplink/Pages/ErreurTrombi.aspx" target="_blank">Une erreur? Cliquez ici</a>
					</div>
				</td>
            </tr>
            <tr>
              <td colspan="7">
			  
				<div id="artPage3" class="bloc_item" style="display: block;">
				<h2><span class="highlight title" style="padding: 0 0 0 15px;">
			  
					<xsl:value-of select="descendant::Service[@Selected = 'True']/@Name"/>
				
				</span></h2>
				</div>
              </td>
            </tr>
            <!--<xsl:apply-templates select="descendant::Service" mode="Middle" />-->
            <xsl:apply-templates select="descendant::Service[@Selected = 'True']" mode="Middle" />
          </table>
        </td>
      </tr>
    </table>
  </xsl:template>
  
  <!-- Left -->
  <xsl:template match="/Services/Service" mode="Left">
	<xsl:if test="not(@Visible = 'False')">
		<tr>
      <td>
        <table cellSpacing="0" cellPadding="0" width="100%" border="0"  style="width: 100%;">
          <tr>
            <td>
              <table class="leftsubNavItem" cellSpacing="0" cellPadding="0" width="100%" border="0">
                <tr class="serviceHeader">
                  <td class="leftsubNavItem" style="width: 100%; white-space: nowrap">
                    <xsl:attribute name="style">
                      <xsl:choose>
                        <xsl:when test="position() != 1">
                          <![CDATA[white-space: nowrap;border-top:solid 1px #dddcdc;background: #f1f1f1;width: 320px;]]>
                        </xsl:when>
                        <xsl:otherwise>
                          <![CDATA[white-space: nowrap; background: #f1f1f1;width: 320px;]]>
                        </xsl:otherwise>
                      </xsl:choose>
                    </xsl:attribute>
                    <span class="leftsubNavItem" style="white-space: normal;list-style: inside square; cursor:pointer;font-size: 1em; border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none;text-transform: uppercase; padding:9px 0 0 15px; height: 24px;" onclick="javascript:selectService(this.getAttribute('id'));document.forms[0].submit();">
                      <xsl:attribute name="id">
                        <xsl:value-of select="@Code"/>
                      </xsl:attribute>
                      <xsl:attribute name="serviceName">
                        <xsl:value-of select="@Code" />
                      </xsl:attribute>
                      <xsl:choose>
                        <xsl:when test="@Selected = 'True'">
                          <xsl:attribute name="id">selected</xsl:attribute>
                          <script type="text/javascript">
                            selectService('selected');
                          </script>
                        </xsl:when>
                        <xsl:otherwise>
                          <xsl:attribute name="id">
                            <xsl:value-of select="@Code"/>
                          </xsl:attribute>
                        </xsl:otherwise>
                      </xsl:choose>
                      <script type="text/javascript">
                        <![CDATA[ services += ']]><xsl:value-of select="@Code" /><![CDATA[' + ';';]]>
                      </script>
                      <xsl:value-of select="@Name" />
                    </span>
                  </td>
                </tr>
                <xsl:if test="count(current()/Service) > 0">
                  <tr>
                      <xsl:choose>
						<xsl:when test="@SelectedDirection = 'True'">
						  <xsl:attribute name="class">selectedBody</xsl:attribute>
						</xsl:when>
						<xsl:otherwise>
						  <xsl:attribute name="class">unselectedBody</xsl:attribute>
						</xsl:otherwise>
                      </xsl:choose>
                    <td class="leftsubNavItem" style="width: 100%; white-space: nowrap; padding-left:10px">
						<xsl:attribute name="style">
						  <xsl:choose>
							<xsl:when test="position() != 1">
							  <![CDATA[border-top:solid 1px #dddcdc; width: 320px;]]>
							</xsl:when>
							<xsl:otherwise>
							  <![CDATA[border-top:solid 1px #dddcdc; width: 320px;]]>
							</xsl:otherwise>
						  </xsl:choose>
						</xsl:attribute>
					  <xsl:apply-templates select="Service" mode="LeftLevel2" />
                    </td>
                  </tr>
                </xsl:if>
              </table>
            </td>
          </tr>
        </table>
      </td>
    </tr>
	</xsl:if>
  </xsl:template>
  
  <xsl:template match="Service" mode="LeftLevel2">
    <table class="leftsubNavItem" cellSpacing="0" cellPadding="0" width="100%" border="0">
      <tr>
        <td class="leftsubNavItem" style="width: 100%; white-space: nowrap">
          <li style="text-transform:capitalize;list-style: inside square; color: #f21e8c; padding-left: 15px;">
		  <a class="leftsubNavItem" style="padding:3px 0 3px 0;cursor:pointer;font-size: 1em; border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none; font-weight: bold;" onclick="javascript:selectService(this.getAttribute('id'));document.forms[0].submit();">
            <xsl:attribute name="id">
              <xsl:value-of select="@Code"/>
            </xsl:attribute>
            <xsl:attribute name="serviceName">
              <xsl:value-of select="@Code" />
            </xsl:attribute>
            <xsl:choose>
              <xsl:when test="@Selected = 'True'">
                <xsl:attribute name="id">selected</xsl:attribute>
                <script type="text/javascript">
                  selectService('selected');
                </script>
              </xsl:when>
              <xsl:otherwise>
                <xsl:attribute name="id">
                  <xsl:value-of select="@Code"/>
                </xsl:attribute>
              </xsl:otherwise>
            </xsl:choose>
            <script type="text/javascript">
              <![CDATA[ services += ']]><xsl:value-of select="@Code"/><![CDATA[' + ';';]]>
            </script>
            <xsl:value-of select="@Name" />
          </a></li>
        </td>
      </tr>
      <xsl:if test="count(current()/Service) > 0">
        <tr>
          <td class="leftsubNavItem" style="width: 100%; white-space: nowrap; padding-left:10px">
            <xsl:apply-templates select="Service" mode="LeftLevel3" />
          </td>
        </tr>
      </xsl:if>
    </table>
  </xsl:template>
  <xsl:template match="Service" mode="LeftLevel3">
    <table class="leftsubNavItem" cellSpacing="0" cellPadding="0" width="100%" border="0">
      <tr>
        <td class="leftsubNavItem" style="width: 100%; white-space: nowrap">
          <li style="list-style: inside square; color: #f21e8c; padding-left: 15px;">
		  <a class="leftsubNavItem" style="padding:3px 0 3px 0px; cursor:pointer;font-size: 1em; border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none" onclick="javascript:selectService(this.getAttribute('id'));document.forms[0].submit();">
            <xsl:attribute name="id">
              <xsl:value-of select="@Code"/>
            </xsl:attribute>
            <xsl:attribute name="serviceName">              
				<xsl:value-of select="@Code" />
            </xsl:attribute>
            <xsl:choose>
              <xsl:when test="@Selected = 'True'">
                <xsl:attribute name="id">selected</xsl:attribute>
                <script type="text/javascript">
                  selectService('selected');
                </script>
              </xsl:when>
              <xsl:otherwise>
                <xsl:attribute name="id">
                  <xsl:value-of select="@Code"/>
                </xsl:attribute>
              </xsl:otherwise>
            </xsl:choose>
            <script type="text/javascript">
              <![CDATA[ services += ']]><xsl:value-of select="@Code"/><![CDATA[' + ';';]]>
            </script>
            <xsl:value-of select="@Name" />
          </a>
		  </li>
        </td>
      </tr>
      <xsl:if test="count(current()/Service) > 0">
        <tr>
			<td class="leftsubNavItem" style="width: 100%; white-space: nowrap; padding-left:10px">
			  <xsl:apply-templates select="Service" mode="LeftLevel3" />
			</td>
        </tr>
      </xsl:if>
    </table>
  </xsl:template>

  <!-- Middle -->
  <xsl:template match="Service" mode="Middle">
     <tr>
      <td>
        <div style="display:block;">
          <xsl:attribute name="id">
            <xsl:value-of select="concat('divService_', @Name, '_', @DirectionCssName)" />
          </xsl:attribute>
          <table>
            <xsl:call-template name="ForLoop-Row">
              <xsl:with-param name="i" select="0" />
              <xsl:with-param name="count" select="//RowCount - 1" />
            </xsl:call-template>
          </table>
        </div>
      </td>
    </tr>
  </xsl:template>
  <xsl:template match="Service/User" mode="Middle">
	<xsl:if test="not(@Visible = 'False')">
		<xsl:if test="@UrlSitePersonnel">
			<a href="{@UrlSitePersonnel}" target="_blank"><img src="{@PictureURL}" border="0"/></a>
		</xsl:if>
		<xsl:if test="not(@UrlSitePersonnel)">
			<img src="{@PictureURL}" border="0"/>
		</xsl:if>
		<span class="trombiInfoPrenom">
		  <xsl:value-of select="@FirstName" />
		</span>
		<span class="trombiInfoNom">
		  <xsl:value-of select="@LastName" />
		</span>
		<span class="trombiInfo">
		  <xsl:value-of select="@Title" />
		</span>
		<xsl:choose>
		  <xsl:when test="normalize-space(@IsManager) = 'True'">
			<![CDATA[<hr class="]]><xsl:value-of select="concat('trombiSeparatorManager-', current()/parent::node()/@DirectionCssName)"/><![CDATA[" />]]>
		  </xsl:when>
		  <xsl:otherwise>
			<![CDATA[<hr class="]]><xsl:value-of select="concat('trombiSeparator-', current()/parent::node()/@DirectionCssName)"/><![CDATA[" />]]>
		  </xsl:otherwise>
		</xsl:choose>
		<span class="trombiInfoFooter">
		  <xsl:value-of select="@WorkPhone" />
		</span><br />
	</xsl:if>
  </xsl:template>
  <xsl:template name="ForLoop-Row">
    <xsl:param name="i" />
    <xsl:param name="count" />
    <!--begin_: Line_by_Line_Output -->
	<xsl:if test="not(User[@RowNumber = $i and @ColumnNumber = 0]/@Visible = 'False')">
		<xsl:if test="$i &lt;= $count">
			<xsl:if test="normalize-space(User[@RowNumber = $i and @ColumnNumber = 0]/@UnrelatedEmplyee) = 'True'">
				<tr class="unrelatedEmployeeRow"><td colspan="5"><div></div></td></tr>
			</xsl:if>
		  <tr>
			<xsl:call-template name="ForLoop-Column">
			  <xsl:with-param name="i" select="$i"/>
			  <xsl:with-param name="j" select="0" />
			  <xsl:with-param name="count" select="//ColumnCount - 1"/>
			</xsl:call-template>
		  </tr>
		</xsl:if>
		<!--begin_: RepeatTheLoopUntilFinished-->
		<xsl:if test="$i &lt;= $count">
		  <xsl:call-template name="ForLoop-Row">
			<xsl:with-param name="i" select="$i + 1"/>
			<xsl:with-param name="count" select="$count"/>
		  </xsl:call-template>
		</xsl:if>
	</xsl:if>
  </xsl:template>
  <xsl:template name="ForLoop-Column">
    <xsl:param name="i" />
    <xsl:param name="j" />
    <xsl:param name="count" />
	<xsl:if test="not(User[@RowNumber = $i and @ColumnNumber = $j]/@Visible = 'False')">
		<!--begin_: Line_by_Line_Output -->
		<xsl:if test="$j &lt;= $count">
		  <!--<td style="vertical-align:top;width:122px;text-align:center;padding:0px 30px 0px 30px">-->
		  <td class="trombiCell">
			<div class="trombiEmpty">
			  <xsl:choose>
				<xsl:when test="normalize-space(User[@RowNumber = $i and @ColumnNumber = $j]/@IsManager) = 'True'">
				  <xsl:attribute name="class">
					<xsl:value-of select="concat('trombiManager',User[@RowNumber = $i and @ColumnNumber = $j]/@Level - User[@RowNumber = $i and @ColumnNumber = $j]/../@ServiceLevel)"/>
				  </xsl:attribute>
				</xsl:when>
				<xsl:when test="normalize-space(User[@RowNumber = $i and @ColumnNumber = $j]/@IsManager) = 'False'">
				  <xsl:attribute name="class">
					<xsl:value-of select="concat('trombi-', @DirectionCssName)"/>
				  </xsl:attribute>
				</xsl:when>
			  </xsl:choose>
			  <xsl:apply-templates select="User[@RowNumber = $i and @ColumnNumber = $j]" mode="Middle" />
			</div>
		  </td>
		</xsl:if>
		<!--begin_: RepeatTheLoopUntilFinished-->
		<xsl:if test="$j &lt;= $count">
		  <xsl:call-template name="ForLoop-Column">
			<xsl:with-param name="i" select="$i"/>
			<xsl:with-param name="j" select="$j + 1"/>
			<xsl:with-param name="count" select="$count"/>
		  </xsl:call-template>
		</xsl:if>
    </xsl:if>
  </xsl:template>
  
</xsl:stylesheet>